﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace HCM_maps_website.Models
{
    public class ServiceType
    {
        int id;
        string picture;
        string description;

        public int ID
        {
            get { return id; }
            set { id = value; }
        }


        public string Description
        {
            get { return description; }
            set { description = value; }
        }


        public string Picture
        {
            get { return picture; }
            set { picture = value; }
        }

        public ServiceType()
        {
        }

        public ServiceType(int id, string desc, string picture)
        {
            ID = id;
            Description = desc;
            Picture = picture;
        }
    }

    public class Coordinate
    {
        double longitude;
        double latitude;

        public double Longitude
        {
            get { return longitude; }
            set { longitude = value; }
        }

        public double Latitude
        {
            get { return latitude; }
            set { latitude = value; }
        }

        public Coordinate()
        {
            longitude = 0;
            latitude = 0;
        }

        public Coordinate(Coordinate p)
        {
            this.latitude = p.latitude;
            this.longitude = p.longitude;
        }

        public Coordinate(double longitude, double latitude)
        {
            this.latitude = latitude;
            this.longitude = longitude;
        }

        public override bool Equals(object obj)
        {
            Coordinate p = (Coordinate)obj;
            if (p.Longitude == this.Longitude && p.Latitude == this.Latitude)
                return true;
            return false;
        }

        public static double Distance(Coordinate p1, Coordinate p2)
        {
            double theta = p1.Longitude - p2.Longitude;
            double dist = Math.Sin(deg2rad(p1.Latitude)) * Math.Sin(deg2rad(p2.Latitude)) + Math.Cos(deg2rad(p1.Latitude)) * Math.Cos(deg2rad(p2.Latitude)) * Math.Cos(deg2rad(theta));
            dist = Math.Acos(dist);
            dist = rad2deg(dist);
            dist = dist * 60 * 1.1515;
            dist = dist * 1.609344;

            return (dist);
        }

        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //::  This function converts decimal degrees to radians             :::
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        public static double deg2rad(double deg)
        {
            return (deg * Math.PI / 180.0);
        }

        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        //::  This function converts radians to decimal degrees             :::
        //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
        public static double rad2deg(double rad)
        {
            return (rad / Math.PI * 180.0);
        }
    }
}